﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Searching.Data
{
    public class WebPage
    {
        private List<string> keywords;
        private string id;

        public WebPage(string id, string []words)
        {
            this.id = id;
            keywords = new List<string>();
            for (int i = 0; i < 5 && i < words.Length; ++i )
            {
                if (!String.IsNullOrEmpty(words[i]))
                {
                    keywords.Add(words[i]);
                }
            }
        }

        public string GetID()
        {
            return id;
        }
        public bool AddKeyWord(string word)
        {
            if (keywords.Count > 5)
                return false;
            else
                keywords.Add(word);
            return true;

        }
        public bool DeleteWord(string word)
        {
            for (int i = 0; i < keywords.Count; ++i )
            {
                if (keywords[i].Equals(word))
                {
                    keywords.RemoveAt(i);
                    return true;
                }
            }
            return false;
        }
        public string[] GetKeywords()
        {
            return keywords.ToArray();
        }
    }
}
